﻿using System;

namespace Factory
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                // 1. 使用Kmeans工厂创建Kmeans算法
                IFactory kmeansFactory = new KmeansFactory();
                IClustering kmeans = kmeansFactory.CreateClustering();
                Console.WriteLine("=== Kmeans算法执行结果 ===");
                Console.WriteLine(kmeans.Calculate());
                Console.WriteLine();

                // 2. 使用Dbscan工厂创建Dbscan算法
                IFactory dbscanFactory = new DbscanFactory();
                IClustering dbscan = dbscanFactory.CreateClustering();
                Console.WriteLine("=== Dbscan算法执行结果 ===");
                Console.WriteLine(dbscan.Calculate());
                Console.WriteLine();

                // 3. 使用层次聚类工厂创建层次聚类算法
                IFactory hierarchicalFactory = new HierarchicalFactory();
                IClustering hierarchical = hierarchicalFactory.CreateClustering();
                Console.WriteLine("=== 层次聚类算法执行结果 ===");
                Console.WriteLine(hierarchical.Calculate());
            }
            catch (Exception ex)
            {
                Console.WriteLine($"程序出错：{ex.Message}");
            }

            Console.ReadLine();
        }
    }
}
